<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="c" %>
<%@ taglib uri="http://richfaces.org/a4j" prefix="a4j" %>
<%@ taglib uri="http://richfaces.org/rich" prefix="rich" %>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Chat Project index</title>
</head>	
<body>
	
	<c:view>
		<p>First page of project Chatter</p>
		<p>Your IP address is: <h:outputText id="userIp" value="#{ipCheckerBean.userIp}" /></p>

		<a4j:region>
	        <h:form>
	            <a4j:poll id="poll" interval="1000" enabled="true" reRender="poll,chats" />
	        </h:form>
    	</a4j:region>
    
    	<a4j:form ajaxSubmit="true" reRender="userChat">
	        <j:panelGrid id="userChat" columns="3" width="200">	   
	        
	        	<h:outputText value="Login:" />     
	        	<h:inputText id="login" value="#{ipCheckerBean.userLogin}"/> 
	        	<h:outputText value=""/>
	        	
	           	<h:outputText value="Text:" />
	           	<h:inputText id="seq" value="#{ipCheckerBean.yourType}"/>
	           	<h:commandButton action="#{ipCheckerBean.addSentense}" value="Send"/>
	                
	        </h:panelGrid>
	    </a4j:form>
	    
	    <h:form>
	        <h:panelGrid columns="1" width="500" id="chats">
	           
	           	<h:outputText value="Chat:" />
	           	<h:dataTable id="allChatsData" value="#{ipCheckerBean.allChats}"
	           		var="chat">
		           	<h:column>
		           		<c:facet name="header">
		           			<h:outputText value="Who"/>
		           		</c:facet>
		           		<h:outputText value="#{chat.who}"/>
		           	</h:column>
		           	<h:column>
		           		<c:facet name="header">
		           			<h:outputText value="Talk"/>
		           		</c:facet>
		           		<h:outputText value="#{chat.sentense}"/>
		           	</h:column>
		           	<h:column>
		           		<c:facet name="header">
		           			<h:outputText value="Date"/>
		           		</c:facet>
		           		<h:outputText value="#{chat.date}"/>
		           	</h:column>
	           	</h:dataTable>
	                
	        </h:panelGrid>
	    </h:form>
    	    
    	    
     <h:form>
        <a4j:push eventProducer="#{push.addListener}"
            reRender="push,out" enabled="true" id="push"/>
            
        <rich:panel>
        <c:facet name="header">
            <h:outputText value="Push Example"/>
        </c:facet>
        
        <h:panelGrid columns="1" id="out">
            <h:panelGroup >
                <h:outputText value="Generated UUID:"/>
                <h:outputText value="#{push.uuid}"/>
            </h:panelGroup>
            <h:panelGroup>
                <a4j:commandButton value="Start" action="#{push.changeUid}"
                    ajaxSingle="true" />
            </h:panelGroup>
        </h:panelGrid>
        </rich:panel>
    </h:form>
    
	</c:view> 
	
</body>
</html>